﻿<style>
    #layer-msg{
        padding: 0px!important;
    }
</style>
<div class="layui-row">
    <div class="layui-col-md3" style="height: 100%;background-color: #fafafa;" id="projecthistory-name">
        <table class="layui-hide" id="table-projectnotehistory" lay-filter="table-projectnotehistory"></table>
    </div>
    <div class="layui-col-md9" style="height: 100%;">
        <div class="content detail" style="padding: 5px;">
            <div class="fly-panel detail-box">
                <h1 id="show-title" style="text-align: center;"></h1>
            </div>
            <div class="fly-detail-info" id="show-info" style="color: #ccc;">
            </div>
            <div class="detail-body " id="show-content" style="padding: 10px 0;overflow: auto;height: 470px;">
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function historyCompare(id) {
        workUtils.put("cid", id);
        workUtils.open({url: "../web/project/compare.html", title: "对比",width:'100%',height:"100%"})
    };
    layui.use(['layer', 'table'], function () {
        table = layui.table;
        table.render({
            elem: '#table-projectnotehistory'
            , url: '../project/listnotehistory/'+workUtils.get("noteId")
            , height: 'full-130'
            , cols: [[
                {field: 'name', title: '标题', align: 'left', event: 'edit'}
            ]]
            , page: true
            , cell: function (field, item) {
                if (field == "created") {
                    return workUtils.toDate(item.created);
                } else if (field == "name") {
                    var html = '<div class="title">' + item.name + '</div>';
                    html += '<div class="layui-row">';
                    html += '<div class="layui-col-md8">';
                    html += workUtils.toDate(item.created,'yyyy-MM-dd hh')+' V'+item.version  +" By "+item.lastUserName;
                    html += '</div>';
                    html += '<div class="layui-col-md4" style="text-align: right;">';
                    html += '<a class="layui-btn layui-btn-normal layui-btn-xs " onclick="historyCompare(' + item.id + ');">对比</a>';
                    html += '</div>';
                    html += '</div>';
                    return html;
                }
                return item[field];
            }
        });
        //监听工具条
        table.on('tool(table-projectnotehistory)', function (obj) {
            var data = obj.data;
            loadOneProjectNote(data.id);
        });
    });
    function loadOneProjectNote(id) {
        $.getJSON("../project/gethistory/" + id, function (data) {
            $("#show-title").html(data.name);
            $("#show-content").html(data.content);
            $("#show-info").html(workUtils.toDate(data.created,'yyyy-MM-dd hh:mm'));
        });
    }
</script>